import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

// const app = createApp(App)

// app.use(createPinia())
// app.use(router)

// app.mount('#app')
let instance = null

function render(props) {
  const { container } = props
  instance = createApp(App)
  instance.use(store).use(router).mount(container ? container.querySelector('#app') : '#app') // 看是否微前端的场景，如果是则挂载到指定的根节点下
}

if (!window.__POWERED_BY_QIANKUN__) {
  // 如果乾坤不存在，走默认挂载，独立运行
  mount({})
}

export async function bootstrap() {
  window.xxx = 2222
  console.log(window.xxx, 123);
}

// 挂载逻辑
export async function mount(props) {
  render(props)
}

// 组件实例卸载流程
export async function unmount() {
  instance.unmount()
  instance = null
}

